import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
import Api from '../api/index'
export default new Vuex.Store({
  state: {
    token:null
  },
  getters: {
  },
  mutations: {
    Token(state,token){
      state.token=token
    }
  },
  actions: {
    async loginAsync(context,forData){
      let red = await Api.login(forData)
      console.log(red);
      if(red.data.code=='00000'){
        alert("登录成功")
        context.commit('Token',red.data.token)
      }else{
        alert('登录失败')
      }
    }
  },
  modules: {
  }
})
